package utilities;

import java.util.ArrayList;

import com.jme3.math.Vector2f;

/*
 * 
 */
public final class PointRotate {
	
	public static void spiralRotate(double freezeDistance, int maxDist, Vector2f point) {
		//if distance < freezeDistance, don't rotate
		double fullRotation = 2*Math.PI;
		
		double distance = Math.sqrt((point.x*point.x) + (point.y*point.y));
		double scaledRotation = (distance-freezeDistance)/maxDist*fullRotation;
		Vector2f vec;
		if (distance > freezeDistance) {
			float x = (float) (point.x*Math.cos(scaledRotation)- point.y*Math.sin(scaledRotation));
			float y = (float) (point.x*Math.sin(scaledRotation)+ point.y*Math.cos(scaledRotation));
		
			point.x = x;
			point.y = y;
		}		
	}
	
	/*
	 * Rotation:  Angle to rotate by, in radians.
	 * Point:  Cartesian x,y point to rotate 
	 */
	public static void simpleRotate(double rotation, Vector2f point) {		
		float x = (float) (point.x*Math.cos(rotation) - point.y*Math.sin(rotation));
		float y = (float) (point.x*Math.sin(rotation) + point.y*Math.cos(rotation));
		
		point.x = x;
		point.y = y;
	}	
	
	public static void simpleRotate(double rotation, ArrayList<Integer> point) {		
		float x = (float) (point.get(0)*Math.cos(rotation) - point.get(1)*Math.sin(rotation));
		float y = (float) (point.get(0)*Math.sin(rotation) + point.get(1)*Math.cos(rotation));
		
		point.set(0,(int) x);
		point.set(1,(int) y);
	}	 
	
}
